<div [@routerTransition]>
    <div class="m-subheader ">
        <div class="d-flex align-items-center">
            <div class="mr-auto col-xs-6">
                <h3 class="m-subheader__title m-subheader__title--separator"><span>基础数据</span></h3>
                <span class="m-section__sub">
                    员工信息管理
                </span>
            </div>
            <div class="col-xs-6 text-right">
                <button (click)="createOrEditUserCardModal.show()" class="btn btn-primary">
                    <i class="fa fa-plus"></i> 新建信息
                </button>
            </div>
        </div>
    </div>

    <div class="m-content">
        <div class="m-portlet m-portlet--mobile">
            <div class="m-portlet__body">
                <form class="horizontal-form" autocomplete="off">
                    <div class="m-form m-form--label-align-right">
                        <div class="row align-items-center m--margin-bottom-10">
                            <div class="col-xl-12">
                                <div class="form-group m-form__group align-items-center">
                                    <div class="input-group">
                                        <input
                                            [(ngModel)]="filterText"
                                            name="filterText"
                                            autoFocus
                                            class="form-control m-input"
                                            [placeholder]="l('SearchWithThreeDot')"
                                            type="text"
                                        />
                                        <span class="input-group-btn">
                                            <button (click)="getUserCards()" class="btn btn-primary" type="submit">
                                                <i class="flaticon-search-1" [attr.aria-label]="l('Search')"></i>
                                            </button>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>

                <div class="row align-items-center">
                    <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                        <p-table
                            #dataTable
                            (onLazyLoad)="getUserCards($event)"
                            [value]="primengTableHelper.records"
                            rows="{{ primengTableHelper.defaultRecordsCountPerPage }}"
                            [paginator]="false"
                            [lazy]="true"
                            [scrollable]="true"
                            ScrollWidth="100%"
                            [responsive]="primengTableHelper.isResponsive"
                            [resizableColumns]="primengTableHelper.resizableColumns"
                        >
                            <ng-template pTemplate="header">
                                <tr>
                                    <th style="width: 150px">{{ l('Actions') }}</th>

                                    <th style="width: 150px">
                                        姓名
                                    </th>
                                    <th style="width: 150px">
                                        卡号
                                    </th>
                                    <th style="width: 150px">
                                        账号
                                    </th>
                                    <th style="width: 150px">
                                        部门
                                    </th>
                                    <th style="width: 150px">
                                        是否启用
                                    </th>
                                </tr>
                            </ng-template>
                            <ng-template pTemplate="body" let-record="$implicit">
                                <tr>
                                    <td style="width: 150px">
                                        <div class="btn-group dropdown" dropdown container="body">
                                            <button dropdownToggle class="dropdown-toggle btn btn-sm btn-primary">
                                                <i class="fa fa-cog"></i><span class="caret"></span>
                                                {{ 'Actions' | localize }}
                                            </button>
                                            <ul class="dropdown-menu" *dropdownMenu>
                                                <li>
                                                    <a
                                                        href="javascript:;"
                                                        (click)="createOrEditUserCardModal.show(record.id)"
                                                        >{{ 'Edit' | localize }}</a
                                                    >
                                                </li>
                                                <li>
                                                    <a href="javascript:;" (click)="deleteUserCard(record)">{{
                                                        'Delete' | localize
                                                    }}</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                    <td style="width: 150px">
                                        {{ record.realName }}
                                    </td>
                                    <td style="width: 150px">
                                        {{ record.cardNumber }}
                                    </td>
                                    <td style="width: 150px">
                                        {{ record.userName }}
                                    </td>
                                    <td style="width: 150px">
                                        {{ record.dept }}
                                    </td>

                                    <td style="width:150px">
                                        <span class="label label-success" *ngIf="record.status === 1">{{
                                            'Yes' | localize
                                        }}</span>
                                        <span class="label label-default" *ngIf="record.status === 0">{{
                                            'No' | localize
                                        }}</span>
                                    </td>
                                </tr>
                            </ng-template>
                        </p-table>
                        <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
                            {{ l('NoData') }}
                        </div>
                        <div class="primeng-paging-container">
                            <p-paginator
                                [rows]="primengTableHelper.defaultRecordsCountPerPage"
                                #paginator
                                (onPageChange)="getUserCards($event)"
                                [totalRecords]="primengTableHelper.totalRecordsCount"
                                [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage"
                            >
                            </p-paginator>
                            <span class="total-records-count">
                                {{ l('TotalRecordsCount', primengTableHelper.totalRecordsCount) }}
                            </span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <createOrEditUserCardModal #createOrEditUserCardModal (modalSave)="getUserCards()"> </createOrEditUserCardModal>
</div>
